package cn.edu.stu.syllabus.utils;

import cn.edu.stu.syllabus.datas.HttpResult;
import rx.Observable;
import rx.functions.Func1;

/**
 * Created by daidaijie on 2017/3/13.
 * 封装HttpResultFun类，只适用于SchoolRetrofit获取的方法
 */

public class SchoolHttpResultFun1<T> implements Func1<HttpResult<T>, Observable<T>> {

    @Override
    public Observable<T> call(HttpResult<T> tHttpResult) {
        if (HttpResult.isHttpSuccessFul(tHttpResult)) {
            return Observable.just(tHttpResult.getData());
        }
        return Observable.error(new Throwable(tHttpResult.getMessage()));
    }
}